#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	int sum = 0x7FFFFFFF;
	int num[3], price[3];
	cin >> n;
	for (int i = 0; i < 3; ++i) {
		cin >> num[i] >> price[i];
	}
	for (int i = 0; i < 3; ++i) {
		if (n % num[i] == 0) {
			if (price[i] * (n / num[i]) < sum)
				sum = price[i] * (n / num[i]);
		} else {
			if (price[i] * (n / num[i] + 1) < sum)
				sum = price[i] * (n / num[i] + 1);
		}
	}
	cout << sum;
	return 0;
}